home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
C++ Toolbox 1.0
/
QuickDraw++.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-28
|
3KB
|
210 lines
#pragma once
/*
File: QuickDraw++.h
Contains: C++ extensions to QuickDraw.
Version: 1.0
Copyright: ©1995 Chris K. Thomas. All Rights Reserved.
*/
//int operator+=(const int &, const int&);
#include "Types++.h"
#include "Memory++.h"
//
// Rectangle class - encapsulate a Mac Rect structure
//
struct Rectangle
{
short top, left, bottom, right;
//
// constructors
//
Rectangle()
{
top = 0;
left = 0;
right = 0;
bottom = 0;
}
Rectangle(Rect &inRect)
{
top = inRect.top;
left = inRect.left;
right = inRect.right;
bottom = inRect.bottom;
}
//
// geometry accessors
//
long width()
{
return right - left;
}
long height()
{
return bottom - top;
}
void hMoveTo(long inOffset)
{
hMoveDelta(-left + inOffset);
// hMoveDelta(inOffset);
}
void vMoveTo(long inOffset)
{
vMoveDelta(-top + inOffset);
}
void hMoveDelta(long inOffset)
{
left += inOffset;
right += inOffset;
}
void vMoveDelta(long inOffset)
{
top += inOffset;
bottom += inOffset;
}
void setSizeFromTopLeft(long inHSize, long inVSize)
{
right = left + inHSize;
bottom = top + inVSize;
}
long hGetCenter()
{
return width()/2 + left;
}
long vGetCenter()
{
return height()/2 + top;
}
//
// conversion operator
//
// we’re a real Rect now.
operator Rect()
{
return *(Rect *)this;
}
operator Rect*()
{
return (Rect *)this;
}
};
class LStream;
class ColorSpecTable
{
HandleArray<ColorSpec> mColorTable;
public:
ColorSpecTable(LStream &inTableStream);
Boolean LookupIndexedColor(long inIndex, RGBColor &outColor);
};
//
// return the center of the end coords. in one dimension
//
inline long CenterPlane(long inStart, long inEnd)
{
return (((inEnd - inStart)/2) + inStart);
}
//
// turn on hilite transfer mode
// only lasts for the duration of the next invert call
//
inline void SetHiliteMode()
{
LMSetHiliteMode(LMGetHiliteMode() & ~(1 << hiliteBit));
}
/*struct ZRGBColor
{
unsigned short red;
unsigned short green;
unsigned short blue;
//
// notational convenience operators
//
bool operator== ( const RGBColor *inRGB1, const RGBColor *inRGB2)
{
bool out = false;
if( (inRGB1->red == inRGB2->red)
&& (inRGB1->green == inRGB2->green)
&& (inRGB1->blue == inRGB2->blue))
out = true;
return out;
}
};*/
//
// notational convenience operators
//
/*bool operator== ( const RGBColor *inRGB1, const RGBColor *inRGB2)
{
bool out = false;
if( (inRGB1->red == inRGB2->red)
&& (inRGB1->green == inRGB2->green)
&& (inRGB1->blue == inRGB2->blue))
out = true;
return out;
}*/
// * Metrowerks support for operator overloading is totally broken
inline bool ComparisonOperatorIsFucked ( const RGBColor& inRGB1, const RGBColor &inRGB2)
{
bool out = false;
if( (inRGB1.red == inRGB2.red)
&& (inRGB1.green == inRGB2.green)
&& (inRGB1.blue == inRGB2.blue))
out = true;
return out;
}
struct StColorSaver
{
RGBColor fore, back;
StColorSaver()
{
GetForeColor(&fore);
GetForeColor(&back);
}
~StColorSaver()
{
RGBForeColor(&fore);
RGBForeColor(&back);
}
};